<?php

/**

 * Created by PhpStorm.

 * User: jingshou

 * Date: 2017/9/17

 * Time: 23:57

 */



namespace app\mobile\model;



use think\Model;

use think\Session;



class TypeModel extends Model

{

    protected $table = 'tp_type';



    public function getList($type, $num)

    {

        return self::where([ 'state' => 0, 'type' => $type])

            ->order('sort asc')

            ->limit($num)

            ->select();

    }



    public function getListAll($type, $typeId = 0)

    {

        return self::where([ 'state' => 0, 'type' => $type])

            ->where(['pId' => $typeId])

            ->order('sort asc')

            ->select();

    }



    public function getInfo($id)

    {

        return self::where(['id' => $id])->find();

    }

     public function getTypename($id)

    {
              return self::where(['id' => $id])->field('typeName')->find();
       
    }

    public function getTypeList($type, $num = 5)

    {

        return self::where(['type' => $type])

            ->order('sort asc')

            ->limit($num)

            ->select();

    }

}